/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Servlet;

import clases.Conexion;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author Alfredo
 */
public class SEliminarCuenta extends HttpServlet {
   
    /** 
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            String cliente=request.getParameter("cliente");

            response.setHeader("Pragma","no-cache");
            response.setHeader("Cache-Control","no-store");
            response.setHeader("Cache", "no-cache");
            response.setDateHeader("Expires",0);

                
            String usuario = "";
            HttpSession sesionOk = request.getSession();
            if (sesionOk.getAttribute("Usuario") == null) {
                response.setContentType("text/html;charset=UTF-8");
                response.sendRedirect("/ProyectoBases2/index.jsp");
            } else {
            usuario = (String)sesionOk.getAttribute("Usuario");
            
            out.println( "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\""+
                               "\"http://www.w3.org/TR/html4/loose.dtd\">"+

                            "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"+
                            "<html xmlns=\"http://www.w3.org/1999/xhtml\">"+
                            "<head>"+
                            "<title>Crear Cuenta Nueva</title>"+
                            "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />"+
                            "<link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\" />"+
                            "<script type=\"text/javascript\" src=\"js/jquery-1.3.2.min.js\"></script>"+
                            "<script type=\"text/javascript\" src=\"js/script.js\"></script>"+
                            "<script type=\"text/javascript\" src=\"js/cufon-yui.js\"></script>"+
                            "<script type=\"text/javascript\" src=\"js/arial.js\"></script>"+
                            "<script type=\"text/javascript\" src=\"js/cuf_run.js\"></script>"+
                            "<meta http-equiv==\"Pragma\" content=\"no-cache\"/>"+
                            "<meta http-equiv=\"Expires\" content=\"-1\"/>"+
                            "<meta http-equiv==\"Cache-Control\" content=\"no-store\"/>"+
                            "<meta http-equiv=\"Cache\" content=\"no-cache\"/>"+
                            "<script lenguaje=\"JavaScript\">"+
                            "if(window.history.forward(1) != null)"+
                                "window.history.forward(1);"+
                            "</script>"+
                            "</head>"+
                            "<body>"+
                            "<div class=\"main\">"+
                              "<div class=\"header\">"+
                                "<div class=\"header_resize\">"+
                                  "<div class=\"logo\">"+
                                   "<h1><a href=\"#\"><span>Siempre</span> a su lado</a></h1>"+
                                  "</div>"+
                                  "<div class=\"menu_nav\">"+
                                    "<ul>"+
                                      "<li> <a href=\"Cuentas_abc.jsp\">Cuentas</a></li>"+
                                      "<li> <a href=\"gerente.jsp\">Principal</a></li>"+
                                      "<li> <a href=\"cerrarsesion.jsp\">Cerrar sesión</a></li>"+
                                     "</ul>"+
                                  "</div>"+
                                  "<div class=\"clr\"></div>"+
                                  "<div class=\"hbg\"><img src=\"images/header_images.jpg\" width=\"400\" height=\"275\" alt=\"\" class=\"fl\" />"+
                                    "<div class=\"info fl\">"+
                                      "<h3>Banco Central <br />"+
                                        "Uniendo al mundo </h3>"+
                                    "</div>"+
                                    "<div class=\"clr\"></div>"+
                                  "</div>"+
                                  "<div class=\"clr\"></div>"+
                                "</div>"+
                              "</div>"+
                              "<div class=\"content\">"+
                                "<div class=\"content_resize\">"+
                                  "<div class=\"mainbar\">"+
                                    "<div class=\"article\">"+
                                      "<h2><span>Eliminando Cuenta</span></h2>");
                                        if(request.getParameter("error")!=null)
                                        {
                                         out.println(request.getParameter("error"));
                                        }
                                       out.println(
                                      "<div class=\"clr\"></div>"+
                                     "</div>"+
                                    "<div class=\"article\">"+
                                     "<div class=\"clr\"></div>");
                                      out.println("<form action="+Conexion.localhost+"EliminarCuenta method='post'>");
                                      //"<form action=\"<%=Conexion.localhost+\"EliminarCuenta\"%>\" method=\"post\">"+
                                        out.println("<ol>"+
                                         "<li>"+
                                          
                                           "<select name=\"cuenta\">");
                                                    //"/**"+
                                                    // "*devolver la lista de los usuarios"+
                                                    // "*/"+
                                                     Conexion mis=new Conexion();
                                                     String t=mis.devolverCuentas(cliente);
                                                     //imprimimos en pantalla"+
                                                     out.println(t);
                                                out.println(
                                            "</select>"+
                                           "<input type=\"submit\" value=\"Eliminar\" align=\"center\" ><br>"+
                                            "<div class=\"clr\"></div>"+
                                          "</li>"+
                                        "</ol>"+
                                      "</form>"+
                                    "</div>"+
                                  "</div>"+
                                  "<div class=\"sidebar\">"+
                                    "<div class=\"gadget\">"+
                                      "<h2 class=\"star\"><span>Nuestro</span> Menu</h2>"+
                                      "<div class=\"clr\"></div>"+
                                      "<ul class=\"sb_menu\">"+
                                        "<li><a href=\"cerrarsesion.jsp\">Cerrar Sesion</a></li>"+
                                        "<li class=\"active\"><a href=\"Cuenta_Nueva.jsp\">Crear Cuenta Nueva</a></li>"+
                                        "<li><a href=\"SEleminar_Cuenta.jsp\">Eliminar Cuenta</a></li>"+
                                        "<li><a href=\"Editar_Estado.jsp\">Cambiar Estado Cuenta</a></li>"+
                                        "<li><a href=\"Solicitar_chequera.jsp\">Solicitar Cheque</a></li>"+
                                        "<li><a href=\"Editar_cheque.jsp\">Cambaiar Estado Cheque</a></li>"+
                                      "</ul>"+
                                    "</div>"+
                                  "</div>"+
                                  "<div class=\"clr\"></div>"+
                                "</div>"+
                              "</div>"+

                              "<div class=\"footer\">"+
                                "<div class=\"footer_resize\">"+
                                  "<p class=\"lf\">&copy; Copyright <a href=\"#\">MyWebSite</a>.</p>"+
                                  "<p class=\"rf\">Layout by I <a href=\"http://www.iwebsitetemplate.com/\">Website Templates</a></p>"+
                                  "<div class=\"clr\"></div>"+
                                "</div>"+
                              "</div>"+
                            "</div>"+
                            "</body>"+
                            "</html>");
            }//fin del else
        } finally { 
            out.close();
        }
    } 

    // <editor-fold defaultstate=\"collapsed\" desc=\"HttpServlet methods. Click on the + sign on the left to edit the code.\">
    /** 
     * Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    } 

    /** 
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

    /** 
     * Returns a short description of the servlet.
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
